Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_wafregional_byte_match_set: Properly read byte_match_tuple into Terraform state #5902

Merged
merged 1 commit into from
Sep 18, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Sep 17, 2018

Fixes #5372

This converts the field_to_match schema.TypeSet with MaxItems: 1 to schema.TypeList for simplification and ensures its properly handled during read.

This also fixes the invalid test configuration being used in TestAccAWSWafRegionalByteMatchSet_changeByteMatchTuples (METHOD fields_to_match type does not use data and the API strips the extraneous data value).

Previously (after adding d.Set() error check):

--- FAIL: TestAccAWSWafRegionalRateBasedRule_changePredicates (21.39s)
    testing.go:527: Step 1 error: Error applying: 1 error occurred:
        	* aws_wafregional_byte_match_set.set: 1 error occurred:
        	* aws_wafregional_byte_match_set.set: error setting byte_match_tuple: Invalid address to set: []string{"byte_match_tuple", "0", "field_to_match"}

Now:

$  make testacc TEST=./aws TESTARGS='-run=TestAccAWSWafRegional\(ByteMatchSet\|RateBasedRule\)_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSWafRegional\(ByteMatchSet\|RateBasedRule\)_ -timeout 120m
=== RUN   TestAccAWSWafRegionalByteMatchSet_basic
--- PASS: TestAccAWSWafRegionalByteMatchSet_basic (14.74s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_changeNameForceNew
--- PASS: TestAccAWSWafRegionalByteMatchSet_changeNameForceNew (25.20s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_changeByteMatchTuples
--- PASS: TestAccAWSWafRegionalByteMatchSet_changeByteMatchTuples (25.18s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_noByteMatchTuples
--- PASS: TestAccAWSWafRegionalByteMatchSet_noByteMatchTuples (10.37s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_disappears
--- PASS: TestAccAWSWafRegionalByteMatchSet_disappears (11.83s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_basic
--- PASS: TestAccAWSWafRegionalRateBasedRule_basic (20.16s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_changeNameForceNew
--- PASS: TestAccAWSWafRegionalRateBasedRule_changeNameForceNew (40.48s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_disappears
--- PASS: TestAccAWSWafRegionalRateBasedRule_disappears (21.64s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_changePredicates
--- PASS: TestAccAWSWafRegionalRateBasedRule_changePredicates (44.00s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_changeRateLimit
--- PASS: TestAccAWSWafRegionalRateBasedRule_changeRateLimit (21.72s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_noPredicates
--- PASS: TestAccAWSWafRegionalRateBasedRule_noPredicates (14.49s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	250.679s

…le into Terraform state

This converts the `field_to_match` `schema.TypeSet` with `MaxItems: 1` to `schema.TypeList` for simplification and ensures its properly handled during read.

This also fixes the invalid test configuration being used in `TestAccAWSWafRegionalByteMatchSet_changeByteMatchTuples` (`METHOD` `fields_to_match` `type` does not use `data` and the API strips the extraneous `data` value).

Previously (after adding `d.Set()` error check):

```
--- FAIL: TestAccAWSWafRegionalRateBasedRule_changePredicates (21.39s)
    testing.go:527: Step 1 error: Error applying: 1 error occurred:
        	* aws_wafregional_byte_match_set.set: 1 error occurred:
        	* aws_wafregional_byte_match_set.set: error setting byte_match_tuple: Invalid address to set: []string{"byte_match_tuple", "0", "field_to_match"}
```

Now:

```
$  make testacc TEST=./aws TESTARGS='-run=TestAccAWSWafRegional\(ByteMatchSet\|RateBasedRule\)_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSWafRegional\(ByteMatchSet\|RateBasedRule\)_ -timeout 120m
=== RUN   TestAccAWSWafRegionalByteMatchSet_basic
--- PASS: TestAccAWSWafRegionalByteMatchSet_basic (14.74s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_changeNameForceNew
--- PASS: TestAccAWSWafRegionalByteMatchSet_changeNameForceNew (25.20s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_changeByteMatchTuples
--- PASS: TestAccAWSWafRegionalByteMatchSet_changeByteMatchTuples (25.18s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_noByteMatchTuples
--- PASS: TestAccAWSWafRegionalByteMatchSet_noByteMatchTuples (10.37s)
=== RUN   TestAccAWSWafRegionalByteMatchSet_disappears
--- PASS: TestAccAWSWafRegionalByteMatchSet_disappears (11.83s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_basic
--- PASS: TestAccAWSWafRegionalRateBasedRule_basic (20.16s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_changeNameForceNew
--- PASS: TestAccAWSWafRegionalRateBasedRule_changeNameForceNew (40.48s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_disappears
--- PASS: TestAccAWSWafRegionalRateBasedRule_disappears (21.64s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_changePredicates
--- PASS: TestAccAWSWafRegionalRateBasedRule_changePredicates (44.00s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_changeRateLimit
--- PASS: TestAccAWSWafRegionalRateBasedRule_changeRateLimit (21.72s)
=== RUN   TestAccAWSWafRegionalRateBasedRule_noPredicates
--- PASS: TestAccAWSWafRegionalRateBasedRule_noPredicates (14.49s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	250.679s
```
@bflad bflad added bug Addresses a defect in current functionality. service/waf Issues and PRs that pertain to the waf service. labels Sep 17, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Sep 17, 2018
@bflad bflad requested a review from a team September 17, 2018 15:28
@bflad bflad added this to the v1.37.0 milestone Sep 18, 2018
@bflad bflad merged commit ba915e0 into master Sep 18, 2018
@bflad bflad deleted the b-aws_wafregional_byte_match_set-schema-error branch September 18, 2018 20:25
bflad added a commit that referenced this pull request Sep 18, 2018
@bflad
Copy link
Contributor Author

bflad commented Sep 19, 2018

This has been released in version 1.37.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/waf Issues and PRs that pertain to the waf service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resource/aws_wafregional_byte_match_set: Unable to detect byte_match_tuple drift
2 participants